package com.bn.feeds.processor;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;

import javax.transaction.SystemException;
import javax.transaction.TransactionManager;

import com.bn.feedMaster.FeedProcessException;
import com.bn.feedMaster.FeedsTools;
import com.bn.feeds.MasterFeedConfiguration;
import com.bn.feeds.utils.FeedConstants;
import com.bn.feeds.utils.FeedFileUtils;

import atg.core.util.StringUtils;
import atg.dtm.TransactionDemarcation;
import atg.dtm.TransactionDemarcationException;
import atg.epub.project.Process;
import atg.nucleus.GenericService;
import atg.process.action.ActionException;
import atg.repository.MutableRepository;
import atg.repository.MutableRepositoryItem;
import atg.repository.RepositoryException;
import atg.repository.RepositoryItem;
import atg.repository.RepositoryView;
import atg.repository.rql.RqlStatement;
import atg.workflow.ActorAccessException;
import atg.workflow.MissingWorkflowDescriptionException;
import au.com.bytecode.opencsv.CSVReader;


/**
 * The Class PriceFeedProcessor.
 */
public class PriceFeedProcessor extends GenericService {

	/** The feed tools. */
	private FeedsTools feedTools;

	/** The file utils. */
	private FeedFileUtils fileUtils;

	/** The batch size. */
	private int batchSize;

	/** The delimiter. */
	private char delimiter;

	/** The list price idx. */
	private int listPriceIdx;

	/** The list locale idx. */
	private int localeIdx;

	/** The sale price idx. */
	private int salePriceIdx;

	/** The sale msrp idx. */
	private int msrpIdx;

	/** The sale unitCost idx. */
	private int unitCostIdx;

	/** The sku id idx. */
	private int skuIdIdx;

	/** The Constant PRICE_QUERY. */
	public static final String PRICE_QUERY = "skuId = ?0 and priceList =?1";

	/** The price list property name. */
	private String priceListPropertyName = "priceList";
	/** The price list property name. */
	private String msrpPriceListId;
	/** The price list property name. */
	private String listPricePriceListId;
	/** The price list property name. */
	private String salePriceListId;
	/** The price list property name. */
	private String unitCostPriceListId;

	/** The sku id property name. */
	private String skuIdPropertyName = "skuId";

	/** The price property name. */
	private String pricePropertyName = "price";

	/** The pricing scheme property name. */
	private String pricingSchemePropertyName = "pricingScheme";

	/** The list price property name. */
	private String listPricePropertyName = "listPrice";

	/** The Constant ERROR_FILE_POST_FIX. */
	private final static String ERROR_FILE_POST_FIX = "_error";

	/** The archive. */
	private boolean archive;

	/**
	 * Process.
	 *
	 * @param pFile
	 *            the file
	 * @param pConfiguration
	 *            the configuration
	 */
	public void process(File pFile, MasterFeedConfiguration pConfiguration) {
		Process process = null;
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:():Starting processing the file: "
					+ pFile);
		}
		List<String[]> priceRecordList = null;
		StringBuilder errorsBuffer = new StringBuilder();

		if (null != pFile) {

			try {
				priceRecordList = getPriceRecordFromFile(pFile);

				if (priceRecordList != null && priceRecordList.size() > 0) {
					if (isLoggingDebug()) {
						logDebug("Ready to process " + priceRecordList.size()+ " from file " + pFile);
					}
					try {
						process = getFeedTools().startProjectInBCC(getPricePropertyName());
					} catch (FeedProcessException e) {
						if (isLoggingError()) {
							logError(e.getMessage());
						}
						errorsBuffer.append("there are some errors while processing files and creating project"
										+ e.getMessage() + "\n");
					} catch (Exception e) {
						errorsBuffer.append("there are some errors while processing files and creating project"
										+ e.getMessage() + "\n");
						if (isLoggingError()) {
							logError(e.getMessage());
						}
					}
					processFileData(priceRecordList, pConfiguration, errorsBuffer);
					try {
						getFeedTools().advanceWorkflow(process);
					} catch (MissingWorkflowDescriptionException e) {
						errorsBuffer
								.append("Exception during automatic publish "
										+ e.getMessage() + "\n");
						if (isLoggingError()) {
							logError(e.getMessage());
						}

					} catch (ActorAccessException e) {
						errorsBuffer.append("Exception during automatic publish "
										+ e.getMessage() + "\n");
						if (isLoggingError()) {
							logError(e.getMessage());
						}

					} catch (UnsupportedOperationException e) {
						errorsBuffer.append("Exception during automatic publish "
										+ e.getMessage() + "\n");
						if (isLoggingError()) {
							logError(e.getMessage());
						}

					} catch (ActionException e) {
						errorsBuffer.append("Exception during automatic publish "
										+ e.getMessage() + "\n");
						if (isLoggingError()) {
							logError(e.getMessage());
						}

					}

					if (isArchive()) {
						getFileUtils().moveToArchive(
								pConfiguration.getArchiveLocation(), pFile);
					}

				}
			} catch (IOException ie) {
				if (isLoggingError()) {
					logError("Exception while Processing Feed: " + ie);
				}
				errorsBuffer.append("Exception while Processing Feed: "
						+ ie.getMessage() + "\n");
			}

			if (errorsBuffer != null) {
				getFileUtils().writeErrorLogToFile(
						(StringBuilder) errorsBuffer,
						pConfiguration.getErrorDirectoryPath(),
						pFile.getName(), ERROR_FILE_POST_FIX);
			}
		}
	}

	/**
	 * Process file data.
	 *
	 * @param priceList
	 *            the price list
	 * @param pConfiguration
	 *            the configuration
	 * @param errorsBuffer
	 *            the errors buffer
	 */
	private void processFileData(List<String[]> priceRecordList,
			MasterFeedConfiguration pConfiguration, StringBuilder errorsBuffer) {
		int count = 1;
		for (String[] row : priceRecordList) {
			if (isLoggingInfo()) {
				logDebug("PriceFeedProcessor : processFileData() : Processing " + count+ " items of "
						+ priceRecordList.size());
			}
			processPriceRecordInfo(row, pConfiguration, errorsBuffer);
			count++;
		}
	}

	/**
	 * Sets the rollback.
	 *
	 * @param td
	 *            the new rollback
	 */
	private void setRollback(TransactionDemarcation td) {
		if (td != null && td.getTransaction() != null) {
			try {
				td.getTransaction().setRollbackOnly();
			} catch (SystemException ex) {
				logError("Error rolling back " + ex.getMessage());
			}
		}
	}

	/**
	 * Process price list info.
	 *
	 * @param pPriceRecord
	 *            the price list info
	 * @param pConfig
	 *            the config
	 * @param errorsBuffer
	 *            the errors buffer
	 */
	protected void processPriceRecordInfo(String[] pPriceRecord,
			MasterFeedConfiguration pConfig, StringBuilder errorsBuffer) {

		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:processPriceRecordInfo():Started...");
		}
		TransactionManager tm = getTransactionManager();
		TransactionDemarcation td = new TransactionDemarcation();
		MutableRepository priceListRepository = pConfig.getRepository();

		String msrpPriceStr = pPriceRecord[getMsrpIdx()];
		String listPriceStr = pPriceRecord[getListPriceIdx()];
		String salePriceStr = pPriceRecord[getSalePriceIdx()];
		String unitCostStr = pPriceRecord[getUnitCostIdx()];
		String locale	= StringUtils.toUpperCase(pPriceRecord[getLocaleIdx()]);
		/*if (msrpPriceStr != null && !"".equals(msrpPriceStr.trim()) && getMsrpPriceListId() != null) {
			try {
				Double price = Double.valueOf(msrpPriceStr);
				if (!price.isNaN() && !price.isInfinite()) {
					createUpdatePriceListAndPrice(pPriceRecord, priceListRepository,
							getMsrpPriceListId(), errorsBuffer, msrpPriceStr, tm,  td);
				}
			} catch (NumberFormatException ne) {
				if (isLoggingError()) {
					logError("NumberFormatException occcured while creating/updating the price", ne);
				}
				errorsBuffer.append("NumberFormatException occcured while creating/updating the price : "
								+ ne.getMessage() + "\n");
			} catch (Exception e) {
				if (isLoggingError()) {
					logError("Exception occcured while creating/updating the price", e);
				}
				errorsBuffer.append("Exception occcured while creating/updating the price : "
								+ e.getMessage() + "\n");
			}
		}*/
		if (listPriceStr != null && !"".equals(listPriceStr.trim()) && getListPricePriceListId() != null) {
			try {
				Double price = Double.valueOf(listPriceStr);
				if (!price.isNaN() && !price.isInfinite()) {
					createUpdatePriceListAndPrice(pPriceRecord, priceListRepository,
							getListPricePriceListId()+"_"+locale, errorsBuffer, listPriceStr, tm,  td);
				}
			} catch (NumberFormatException ne) {
				if (isLoggingError()) {
					logError("NumberFormatException occcured while creating/updating the price",
							ne);
				}
				errorsBuffer.append("NumberFormatException occcured while creating/updating the price : "
								+ ne.getMessage() + "\n");
			} catch (Exception e) {
				if (isLoggingError()) {
					logError("Exception occcured while creating/updating the price", e);
				}
				errorsBuffer.append("Exception occcured while creating/updating the price : "
								+ e.getMessage() + "\n");
			}
		}
		if (salePriceStr != null && !"".equals(salePriceStr.trim()) && getSalePriceListId() != null) {
			try {
				Double price = Double.valueOf(salePriceStr);
				if (!price.isNaN() && !price.isInfinite()) {
					createUpdatePriceListAndPrice(pPriceRecord, priceListRepository,
							getSalePriceListId()+"_"+locale, errorsBuffer, salePriceStr, tm,  td);
				}
			} catch (NumberFormatException ne) {
				if (isLoggingError()) {
					logError("NumberFormatException occcured while creating/updating the price", ne);
				}
				errorsBuffer.append("NumberFormatException occcured while creating/updating the price : "
								+ ne.getMessage() + "\n");
			} catch (Exception e) {
				if (isLoggingError()) {
					logError("Exception occcured while creating/updating the price", e);
				}
				errorsBuffer.append("Exception occcured while creating/updating the price : "
								+ e.getMessage() + "\n");
			}
		}
		/*if (unitCostStr != null && !"".equals(unitCostStr.trim()) && getUnitCostPriceListId() != null) {
			try {
				Double price = Double.valueOf(unitCostStr);
				if (!price.isNaN() && !price.isInfinite()) {
					createUpdatePriceListAndPrice(pPriceRecord, priceListRepository,
							getUnitCostPriceListId(), errorsBuffer, unitCostStr, tm,  td);
				}
			} catch (NumberFormatException ne) {
				if (isLoggingError()) {
					logError("NumberFormatException occcured while creating/updating the price",ne);
				}
				errorsBuffer.append("NumberFormatException occcured while creating/updating the price : "
								+ ne.getMessage() + "\n");
			} catch (Exception e) {
				if (isLoggingError()) {
					logError("Exception occcured while creating/updating the price", e);
				}
				errorsBuffer.append("Exception occcured while creating/updating the price : "
								+ e.getMessage() + "\n");
			}
		}*/

		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:processPriceListInfo():End...");
		}
	}
	protected void createUpdatePriceListAndPrice(String[] pPriceRecord,
			MutableRepository priceListRepository,
			String priceListId, StringBuilder errorsBuffer, String price, TransactionManager tm, TransactionDemarcation td) throws RepositoryException,
			Exception {
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:createPriceData():Started...");
		}
		try {
			td.begin(tm, TransactionDemarcation.REQUIRES_NEW);
			RepositoryItem priceListItem = priceListRepository.getItem(priceListId, getPriceListPropertyName());
			if (priceListItem == null) {
				priceListItem = createPriceListItem(priceListId.trim(), priceListRepository,pPriceRecord[getLocaleIdx()]);
			}
			if (priceListItem != null) {
				if (isLoggingDebug()) {
					logDebug("PriceFeedProcessor:processPriceListInfo():Price List Exist : "
							+ priceListItem.getRepositoryId());
				}
				createOrUpdatePrice(pPriceRecord, priceListRepository, (MutableRepositoryItem) priceListItem, price);
			}
		} catch (RepositoryException e) {
			setRollback(td);
			if (isLoggingError()) {
				logError(e.getMessage());
			}
			errorsBuffer.append("Error while creating a item :"
							+ pPriceRecord[getSkuIdIdx()]
							+ " RepositoryException : "
							+ e.getMessage() + "\n");
		} catch (TransactionDemarcationException tde) {
			setRollback(td);
			if (isLoggingError()) {
				logError("Exception occcured while Ending transaction",tde);
			}
			errorsBuffer.append("Exception occcured while Ending transaction : "
							+ tde.getMessage() + "\n");
		} catch (Exception exe) {
			setRollback(td);
			if (isLoggingError()) {
				logError("Exception occcured while creating/updating the price",exe);
			}
			errorsBuffer.append("Exception occcured while creating/updating the price : "
							+ exe.getMessage() + "\n");
		} finally {
			try {
				if (td != null)
					td.end();
			} catch (TransactionDemarcationException tde) {
				if (isLoggingError()) {
					logError("Exception occcured while Ending transaction", tde);
				}
				errorsBuffer.append("Exception occcured while Ending transaction : "
								+ tde.getMessage() + "\n");
			}
		}
	}
	/**
	 * Creates the price list for store.
	 *
	 * @param priceListId
	 *            the price list id
	 * @param pPriceRecord
	 *            the price list info
	 * @param priceListRepository
	 *            the price list repository
	 * @throws RepositoryException
	 *             the repository exception
	 * @throws Exception
	 *             the exception
	 */

	private RepositoryItem createPriceListItem(String priceListId, MutableRepository priceListRepository, String locale)
			throws RepositoryException, Exception {
		MutableRepositoryItem newPriceListItem = createPriceListData(
				priceListId, priceListRepository, locale);
		return priceListRepository.addItem(newPriceListItem);
	}

	/**
	 * Creates the or update price.
	 *
	 * @param pPriceRecord
	 *            the price list info
	 * @param priceListRepository
	 *            the price list repository
	 * @param newPriceListItem
	 *            the new price list item
	 * @throws RepositoryException
	 *             the repository exception
	 * @throws Exception
	 *             the exception
	 */
	private void createOrUpdatePrice(String[] pPriceRecord,
			MutableRepository priceListRepository,
			MutableRepositoryItem newPriceListItem, String price) throws RepositoryException,
			Exception {
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:createPriceData():Started...");
		}
		String skuId = pPriceRecord[getSkuIdIdx()];
		Object[] pValue = new Object[2];
		pValue[0] = skuId;
		pValue[1] = newPriceListItem.getRepositoryId();
		RepositoryItem priceItem = queryPriceItem(pValue,
				getSkuIdPropertyName(), getPricePropertyName(), priceListRepository);
		if (priceItem != null) {
			updatePriceItem(priceListRepository, priceItem, newPriceListItem,
					pPriceRecord, price.trim());
		} else {
			createPriceItem(priceListRepository, newPriceListItem,
					pPriceRecord, price.trim());
		}
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:createPriceData():End...");
		}
	}

	/**
	 * Creates the price item.
	 *
	 * @param priceListRepository
	 *            the price list repository
	 * @param newPriceListItem
	 *            the new price list item
	 * @param pPriceRecord
	 *            the price list info
	 * @throws RepositoryException
	 *             the repository exception
	 * @throws Exception
	 *             the exception
	 */
	private void createPriceItem(MutableRepository priceListRepository,
			MutableRepositoryItem newPriceListItem, String[] pPriceRecord, String price)
			throws RepositoryException, Exception {
		MutableRepositoryItem mutablePriceItem = priceListRepository.createItem(getPricePropertyName());
		mutablePriceItem = setPriceProperties(mutablePriceItem, newPriceListItem, pPriceRecord, price);
		priceListRepository.addItem(mutablePriceItem);

	}

	/**
	 * Update price item.
	 *
	 * @param priceListRepository
	 *            the price list repository
	 * @param priceItem
	 *            the price item
	 * @param newPriceListItem
	 *            the new price list item
	 * @param pPriceRecord
	 *            the price list info
	 * @throws RepositoryException
	 *             the repository exception
	 * @throws Exception
	 *             the exception
	 */
	private void updatePriceItem(MutableRepository priceListRepository,
			RepositoryItem priceItem, MutableRepositoryItem newPriceListItem,
			String[] pPriceRecord, String price) throws RepositoryException, Exception {
		MutableRepositoryItem updatePriceItem = priceListRepository
				.getItemForUpdate(priceItem.getRepositoryId(), getPricePropertyName());
		updatePriceItem = setPriceProperties(updatePriceItem, newPriceListItem, pPriceRecord, price);
		priceListRepository.updateItem(updatePriceItem);
	}

	/**
	 * Sets the price properties.
	 *
	 * @param pMutablePriceItem
	 *            the mutable price item
	 * @param pPriceListItem
	 *            the price list item
	 * @param pPriceRecord
	 *            the price list info
	 * @return the mutable repository item
	 * @throws RepositoryException
	 *             the repository exception
	 * @throws Exception
	 *             the exception
	 */
	private MutableRepositoryItem setPriceProperties(
			MutableRepositoryItem pMutablePriceItem,
			MutableRepositoryItem pPriceListItem, String[] pPriceRecord, String price)
			throws RepositoryException, Exception {
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:setPriceProperties():Started...");
		}
		String skuId = pPriceRecord[getSkuIdIdx()];
		pMutablePriceItem = setCommonPriceProperties(pMutablePriceItem,
				pPriceListItem, skuId);

		if (price != null) {
			pMutablePriceItem = setListPriceProperties(pMutablePriceItem, price);
		}
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:setPriceProperties():End...");
		}

		return pMutablePriceItem;
	}

	/**
	 * Sets the sale price properties.
	 *
	 * @param pMutablePriceItem
	 *            the mutable price item
	 * @param salePrice
	 *            the sale price
	 * @param saleWeightSw
	 *            the sale weight sw
	 * @param salePriceXFor
	 *            the sale price x for
	 * @param saleXForQty
	 *            the sale x for qty
	 * @return the mutable repository item
	 * @throws Exception
	 *             the exception
	 */
/*	private MutableRepositoryItem setSalePriceProperties(
			MutableRepositoryItem pMutablePriceItem, String salePrice,
			String saleWeightSw, String salePriceXFor, String saleXForQty)
			throws Exception {
		pMutablePriceItem.setPropertyValue(getListPricePropertyName(),
				Double.valueOf(salePrice));

		if (saleWeightSw != null && saleWeightSw.equalsIgnoreCase("Y")) {
			pMutablePriceItem.setPropertyValue(getIsWeightPropertyName(),
					Boolean.TRUE);
		} else if (saleWeightSw != null && saleWeightSw.equalsIgnoreCase("N")) {
			pMutablePriceItem.setPropertyValue(getIsWeightPropertyName(),
					Boolean.FALSE);
		}

		if (salePriceXFor != null
				&& !org.apache.commons.lang3.StringUtils.isEmpty(salePriceXFor)) {
			pMutablePriceItem.setPropertyValue(getxForPricePropertyName(),
					Double.valueOf(salePriceXFor));
		}

		if (saleXForQty != null && !saleXForQty.isEmpty()) {
			pMutablePriceItem.setPropertyValue(getxForQuantityPropertyName(),
					Long.valueOf(saleXForQty));
		}

		return pMutablePriceItem;
	}
*/
	/**
	 * Sets the list price properties.
	 *
	 * @param pMutablePriceItem
	 *            the mutable price item
	 * @param listPrice
	 *            the list price
	 * @param listWeightSw
	 *            the list weight sw
	 * @param listPriceXFor
	 *            the list price x for
	 * @param listXForQty
	 *            the list x for qty
	 * @return the mutable repository item
	 * @throws Exception
	 *             the exception
	 */
	private MutableRepositoryItem setListPriceProperties(MutableRepositoryItem pMutablePriceItem,
			String listPrice) throws Exception {

		pMutablePriceItem.setPropertyValue(getListPricePropertyName(), Double.valueOf(listPrice));

		return pMutablePriceItem;
	}

	/**
	 * Sets the common price properties.
	 *
	 * @param pMutablePriceItem
	 *            the mutable price item
	 * @param pPriceListItem
	 *            the price list item
	 * @param pSkuId
	 *            the sku id
	 * @param pOnSale
	 *            the on sale
	 * @return the mutable repository item
	 */
	protected MutableRepositoryItem setCommonPriceProperties(
			MutableRepositoryItem pMutablePriceItem,
			MutableRepositoryItem pPriceListItem, String pSkuId) {

		pMutablePriceItem.setPropertyValue(getPriceListPropertyName(),
				pPriceListItem);
		pMutablePriceItem.setPropertyValue(getSkuIdPropertyName(), pSkuId);
		pMutablePriceItem.setPropertyValue(getPricingSchemePropertyName(),
				getListPricePropertyName());
		return pMutablePriceItem;
	}

	/**
	 * Query price item.
	 *
	 * @param pValue
	 *            the value
	 * @param pPropertyName
	 *            the property name
	 * @param pItemType
	 *            the item type
	 * @param priceListRepository
	 *            the price list repository
	 * @return the repository item
	 * @throws RepositoryException
	 *             the repository exception
	 */
	public RepositoryItem queryPriceItem(final Object pValue[],
			final String pPropertyName, final String pItemType,
			MutableRepository priceListRepository) throws RepositoryException {
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:queryPriceItem():Start...");
		}
		RepositoryItem item = null;
		RepositoryView view = priceListRepository.getView(pItemType);
		RqlStatement statement = RqlStatement.parseRqlStatement(PRICE_QUERY);
		RepositoryItem[] items = statement.executeQuery(view, pValue);
		if (items != null) {
			item = items[0];
		}
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:queryPriceItem():End...");
		}
		return item;
	}

	/**
	 * Creates the price list data.
	 *
	 * @param priceListId
	 *            the price list id
	 * @param pPriceRecord
	 *            the price list info
	 * @param priceListRepository
	 *            the price list repository
	 * @return the mutable repository item
	 */
	private MutableRepositoryItem createPriceListData(String priceListId,
			MutableRepository priceListRepository, String locale) {
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:createPriceListData():Started...");
		}
		MutableRepositoryItem priceListItem = null;
		try {
			priceListItem = priceListRepository.createItem(priceListId, getPriceListPropertyName());

			priceListItem.setPropertyValue("displayName", priceListId);
			if(locale != null && !locale.isEmpty()){
				priceListItem.setPropertyValue("locale", locale);
			}else{
				priceListItem.setPropertyValue("locale", FeedConstants.STR_EN_US);
			}
		} catch (RepositoryException e) {
			if (isLoggingError()) {
				logError(e.getMessage());
			}

		}
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:createPriceListData():End...");
		}
		return priceListItem;
	}

	/**
	 * Gets the price list from file.
	 *
	 * @param pFile
	 *            the file
	 * @return the price list from file
	 * @throws IOException
	 *             Signals that an I/O exception has occurred.
	 */
	private List<String[]> getPriceRecordFromFile(File pFile) throws IOException {
		if (isLoggingDebug()) {
			logDebug("PriceFeedProcessor:getPriceRecordFromFile:Reading file: "
					+ pFile);
		}
		CSVReader parser = new CSVReader(new FileReader(pFile), getDelimiter());
		List<String[]> priceList = parser.readAll();
		// Remove the header
		priceList.remove(0);
		priceList.remove(0);
		priceList.remove(priceList.size()-1);

		return priceList;
	}

	/** The transaction manager. */
	private TransactionManager transactionManager;

	/**
	 * Gets the transaction manager.
	 *
	 * @return the transactionManager
	 */
	public TransactionManager getTransactionManager() {
		return transactionManager;
	}

	/**
	 * Sets the transaction manager.
	 *
	 * @param transactionManager
	 *            the transactionManager to set
	 */
	public void setTransactionManager(TransactionManager transactionManager) {
		this.transactionManager = transactionManager;
	}

	/**
	 * Gets the price query.
	 *
	 * @return the priceQuery
	 */
	public static String getPriceQuery() {
		return PRICE_QUERY;
	}

	/**
	 * Gets the delimiter.
	 *
	 * @return the delimiter
	 */
	public char getDelimiter() {
		return delimiter;
	}

	/**
	 * Sets the delimiter.
	 *
	 * @param delimiter
	 *            the delimiter to set
	 */
	public void setDelimiter(char delimiter) {
		this.delimiter = delimiter;
	}

	/**
	 * Gets the list price idx.
	 *
	 * @return the listPriceIdx
	 */
	public int getListPriceIdx() {
		return listPriceIdx;
	}

	/**
	 * Sets the list price idx.
	 *
	 * @param listPriceIdx
	 *            the listPriceIdx to set
	 */
	public void setListPriceIdx(int listPriceIdx) {
		this.listPriceIdx = listPriceIdx;
	}

	/**
	 * Gets the sale price idx.
	 *
	 * @return the salePriceIdx
	 */
	public int getSalePriceIdx() {
		return salePriceIdx;
	}

	/**
	 * Sets the sale price idx.
	 *
	 * @param salePriceIdx
	 *            the salePriceIdx to set
	 */
	public void setSalePriceIdx(int salePriceIdx) {
		this.salePriceIdx = salePriceIdx;
	}
	/**
	 * Gets the sku id idx.
	 *
	 * @return the skuIdIdx
	 */
	public int getSkuIdIdx() {
		return skuIdIdx;
	}

	/**
	 * Sets the sku id idx.
	 *
	 * @param skuIdIdx
	 *            the skuIdIdx to set
	 */
	public void setSkuIdIdx(int skuIdIdx) {
		this.skuIdIdx = skuIdIdx;
	}


	/**
	 * Gets the price list property name.
	 *
	 * @return the priceListPropertyName
	 */
	public String getPriceListPropertyName() {
		return priceListPropertyName;
	}

	/**
	 * Sets the price list property name.
	 *
	 * @param priceListPropertyName
	 *            the priceListPropertyName to set
	 */
	public void setPriceListPropertyName(String priceListPropertyName) {
		this.priceListPropertyName = priceListPropertyName;
	}

	/**
	 * Gets the sku id property name.
	 *
	 * @return the skuIdPropertyName
	 */
	public String getSkuIdPropertyName() {
		return skuIdPropertyName;
	}

	/**
	 * Sets the sku id property name.
	 *
	 * @param skuIdPropertyName
	 *            the skuIdPropertyName to set
	 */
	public void setSkuIdPropertyName(String skuIdPropertyName) {
		this.skuIdPropertyName = skuIdPropertyName;
	}

	/**
	 * Gets the price property name.
	 *
	 * @return the pricePropertyName
	 */
	public String getPricePropertyName() {
		return pricePropertyName;
	}

	/**
	 * Sets the price property name.
	 *
	 * @param pricePropertyName
	 *            the pricePropertyName to set
	 */
	public void setPricePropertyName(String pricePropertyName) {
		this.pricePropertyName = pricePropertyName;
	}


	/**
	 * Gets the list price property name.
	 *
	 * @return the listPricePropertyName
	 */
	public String getListPricePropertyName() {
		return listPricePropertyName;
	}

	/**
	 * Sets the list price property name.
	 *
	 * @param listPricePropertyName
	 *            the listPricePropertyName to set
	 */
	public void setListPricePropertyName(String listPricePropertyName) {
		this.listPricePropertyName = listPricePropertyName;
	}

	/**
	 * Gets the pricing scheme property name.
	 *
	 * @return the pricingSchemePropertyName
	 */
	public String getPricingSchemePropertyName() {
		return pricingSchemePropertyName;
	}

	/**
	 * Sets the pricing scheme property name.
	 *
	 * @param pricingSchemePropertyName
	 *            the pricingSchemePropertyName to set
	 */
	public void setPricingSchemePropertyName(String pricingSchemePropertyName) {
		this.pricingSchemePropertyName = pricingSchemePropertyName;
	}

	/**
	 * Gets the batch size.
	 *
	 * @return the batchSize
	 */
	public int getBatchSize() {
		return batchSize;
	}

	/**
	 * Sets the batch size.
	 *
	 * @param batchSize
	 *            the batchSize to set
	 */
	public void setBatchSize(int batchSize) {
		this.batchSize = batchSize;
	}

	/**
	 * Gets the file utils.
	 *
	 * @return the fileUtils
	 */
	public FeedFileUtils getFileUtils() {
		return fileUtils;
	}

	/**
	 * Sets the file utils.
	 *
	 * @param fileUtils
	 *            the fileUtils to set
	 */
	public void setFileUtils(FeedFileUtils fileUtils) {
		this.fileUtils = fileUtils;
	}

	/**
	 * Checks if is archive.
	 *
	 * @return the archive
	 */
	public boolean isArchive() {
		return archive;
	}

	/**
	 * Sets the archive.
	 *
	 * @param archive
	 *            the archive to set
	 */
	public void setArchive(boolean archive) {
		this.archive = archive;
	}
	/**
	 * Gets the feed tools.
	 *
	 * @return the feedTools
	 */
	public FeedsTools getFeedTools() {
		return feedTools;
	}

	/**
	 * Sets the feed tools.
	 *
	 * @param feedTools
	 *            the feedTools to set
	 */
	public void setFeedTools(FeedsTools feedTools) {
		this.feedTools = feedTools;
	}

	public String getMsrpPriceListId() {
		return msrpPriceListId;
	}

	public void setMsrpPriceListId(String msrpPriceListId) {
		this.msrpPriceListId = msrpPriceListId;
	}

	public String getListPricePriceListId() {
		return listPricePriceListId;
	}

	public void setListPricePriceListId(String listPricePriceListId) {
		this.listPricePriceListId = listPricePriceListId;
	}

	public String getSalePriceListId() {
		return salePriceListId;
	}

	public void setSalePriceListId(String salePriceListId) {
		this.salePriceListId = salePriceListId;
	}

	public String getUnitCostPriceListId() {
		return unitCostPriceListId;
	}

	public void setUnitCostPriceListId(String unitCostPriceListId) {
		this.unitCostPriceListId = unitCostPriceListId;
	}
	public int getMsrpIdx() {
		return msrpIdx;
	}

	public void setMsrpIdx(int saleMsrpIdx) {
		this.msrpIdx = saleMsrpIdx;
	}

	public int getUnitCostIdx() {
		return unitCostIdx;
	}

	public void setUnitCostIdx(int unitCostIdx) {
		this.unitCostIdx = unitCostIdx;
	}

	public int getLocaleIdx() {
		return localeIdx;
	}

	public void setLocaleIdx(int localeIdx) {
		this.localeIdx = localeIdx;
	}


}
